package cate.game.util.api;

import cate.game.GameBody;
import cate.game.log.GameLoggerFactory;
import cate.game.role.Role;
import cp.solution.business.sys.account.AccountRoleEntity;
import easy.java.practice.errorcode.EcException;

public class LoginApi {

    public static void regToLogin(GameBody game, Role role) throws EcException {
        AccountRoleEntity ar = new AccountRoleEntity();
        ar.setRoleId(role.getUid());
        ar.setAccountId(role.getBase().accountId);
        ar.setRoleLevel(role.getBase().level);
        ar.setRoleName(role.getBase().name);
        ar.setRoleHeadIcon(""+role.getBase().headIcon.tid);
        ar.setSrvId(game.config.srvId);
        ar.setSrvIdOrigin(role.getBase().srvIdOrigin);
        ar.setSrvName(game.config.gs.getName());
        ar.setGroupCode(game.config.gs.getGroupCode());
        ar.setGameId(role.getBase().gameId);
        ar.setUpdateTime(System.currentTimeMillis());
        int n = game.apis().login.account.addRole(ar);
        GameLoggerFactory.getLogger(game, LoginApi.class).info("向LoginServer注册AccountRole,n={}", n);
    }
}
